package com.itheima.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/*
    让一个servlet能够执行不同功能(方法)
        解决方式:
        1.通过请求发送不同的参数值
            明确指定一个key
     http://localhost:8080/虚拟路径/demo16?method=findAll



        一个servlet处理一个模块的功能
 */

@WebServlet("/demo16")
public class ServletDemo16 extends HttpServlet {
    //自调用方法 只访问service 无法访问其他方法
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取method值
        String method = req.getParameter("method");

        if ("findAll".equals(method)){
            findAll(req,resp);
        }else if ("update".equals(method)){
            update(req,resp);
        }
    }




    private void findAll(HttpServletRequest req, HttpServletResponse resp){
        System.out.println("findAll....");
    }
    private void update(HttpServletRequest req, HttpServletResponse resp){
        System.out.println("update....");
    }

}
